package net.alcuria.ball;

public class Object {
	
	boolean render = true;
	Sprite sprite;
	int x, y, type;
	int collisionTimeout = 20;
	
	public Object(int x, int y, int type, Sprite sprite){
		this.x = x;
		this.y = y;
		this.sprite = sprite;
		this.type = type;
	}
	
	public void update(float deltaTime){
		sprite.update(deltaTime);
		collisionTimeout++;
	}
	
	public boolean checkCollision(float ballX, float ballY){
		
		int objCenterX = x + sprite.frameWidth/2;
		int objCenterY = y + sprite.frameHeight/2;
		
		int ballCenterX = (int)ballX + 24;
		int ballCenterY = (int)ballY + 24;
		
		int dist = (int) (Math.abs(ballCenterX - objCenterX) + Math.abs(ballCenterY - objCenterY));
		
		return dist <= 40;
		
	}

}
